import { get as _get, cloneDeep, sortBy, uniqBy, throttle } from 'lodash'
import {
  invStatus, reconcileStatus, bookkeepingStatus, getBankCardList, getBankTypeList,
  getPersonnelList, getDeptList, getProjectsList, getCustomerList,
  getInvoiceList, goodsDict, getBusinessNoType, getPayStatusList,
  customerDetail,
  getBankCardByTaxId,
  getTaxRateList
} from '@/api/invoiceManagement'
export default (dataType) => {
  const isList = dataType === 'list'
  const isFunc = dataType === 'func'
  const { optionsResult } = getOptionBaseType()

  // 修改、详情页的配置,即需要提交的表单
  const funcPageSet = ['businessNo', 'taxOrgId', 'invCompanyTaxSubjectNum', 'invCompanyAddress', 'invCompanySubBank', 'invCompanyBankAccount', 'applyUser', 'deptId', 'applyDate', 'projectId', 'custId', 'custTaxNum', 'custAddress', 'custSubBank', 'custBankAccount', 'invTypeId', 'payStatus', 'amount', 'extTaxAmount', 'taxAmount', 'remark']
  // 新增页，不可展示:流水状态、对账状态、记账状态
  const funcPageSetOnlyAddShow = ['invStatus', 'reconcile', 'bookkeeping']

  let _setTempThis = {}
  let mixin = {
    created() {
      _setTempThis = this
    },
    mounted() {
      // 获取申请编号
      this.getBusinessNo()
      this.setFuncPageOptions()
    },
    data() {
      return {
        defaultFormBody: {
          goodsId: '',
          invoiceType: '',
          specification: '',
          unit: '',
          num: '',
          price: '',
          sumPriceTax: '',
          tax: '',
          taxAmount: '',
          extTaxAmount: '',
          invDate: '',
          invCode: '',
          invNum: ''
        },
        option: {
          ...optionsResult,
          column: [
            {
              label: '申请编号',
              prop: 'businessNo',
              disabled: true
            },
            { ...taxpayerSelector('纳税主体', 'taxOrgName') },
            {
              label: '开票单位纳税人识别号',
              prop: 'invCompanyTaxSubjectNum',
              rules: isFunc ? [{ required: true, message: '开票单位纳税人识别号', trigger: 'change' }] : null,
              disabled: !!isFunc
            },
            {
              label: '纳税主体地址、电话',
              prop: 'invCompanyAddress',
              rules: isFunc ? [{ required: true, message: '纳税主体地址、电话', trigger: 'change' }] : null,
              disabled: !!isFunc
            },
            { ...bankSelector('纳税主体开户行', 'invCompanySubBank') },
            // {
            //   label: '纳税主体开户行',
            //   prop: 'invCompanySubBank',
            //   rules: isFunc ? [{ required: true, message: '纳税主体开户行', trigger: 'change' }] : null,
            //   disabled: !!isFunc
            // },
            // { ...invCompanyBankAccountSelector('纳税主体银行账号', 'invCompanyBankAccount') },
            {
              label: '纳税主体银行账号',
              prop: 'invCompanyBankAccount',
              rules: isFunc ? [{ required: true, message: '纳税主体银行账号', trigger: 'change' }] : null,
              disabled: !!isFunc
            },
            { ...applyUserSelector('申请人', 'applyUserName') }, // table展示
            { ...applyUserSelector('申请人', 'applyUser') }, // 编辑新增
            { ...deptSelector() },
            { ...applyDateSeting('申请日期', 'applyDate', true) },
            { ...projectSelector() },
            { ...custSelector('客户名称', 'custName', true) },
            {
              label: '客户纳税人识别号',
              prop: 'custTaxNum',
              rules: isFunc ? [{ required: true, message: '客户纳税人识别号', trigger: 'change' }] : null,
              disabled: !!isFunc
            },
            {
              label: '客户地址、电话',
              prop: 'custAddress',
              rules: isFunc ? [{ required: true, message: '客户地址、电话', trigger: 'change' }] : null,
              disabled: !!isFunc
            },
            { ...bankSelector('客户开户行', 'custSubBank') },
            // {
            //   label: '客户开户行',
            //   prop: 'custSubBank',
            //   rules: isFunc ? [{ required: true, message: '客户开户行', trigger: 'change' }] : null,
            //   disabled: !!isFunc
            // },
            {
              label: '客户银行账号',
              prop: 'custBankAccount',
              rules: isFunc ? [{ required: true, message: '客户银行账号', trigger: 'change' }] : null,
              disabled: !!isFunc
            },

            { ...invTypeSelector('发票类型', 'invTypeName') },
            { ...payStatusSelector('回款类型', 'payStatusName') },
            {
              label: '开票总金额',
              prop: 'amount'
            },
            {
              label: '不含税总金额',
              prop: 'extTaxAmount'
            },

            {
              label: '总税额',
              prop: 'taxAmount'
            },
            {
              label: '流水状态',
              prop: 'invStatus',
              type: 'select',
              dicUrl: invStatus(),
              search: true,
              props: {
                label: 'name', value: 'code'
              }
            },
            {
              label: '对账状态',
              prop: 'reconcile',
              type: 'select',
              dicUrl: reconcileStatus(),
              // search: true,
              props: {
                label: 'name', value: 'code'
              }
            },
            {
              label: '记账状态',
              prop: 'bookkeeping',
              type: 'select',
              dicUrl: bookkeepingStatus(),
              search: true,
              props: {
                label: 'name', value: 'code'
              }
            },
            {
              label: '备注',
              prop: 'remark'
            },

            { ...taxpayerSelector('纳税主体', 'taxOrgId') },

            { ...applyUserSelector('申请人', 'applicant') },
            { ...applyDateSeting('申请日期', 'applyDate') },
            {
              label: '申请单据号',
              prop: 'businessNo',
              search: true,
              hide: true,
              display: false
            },

            { ...custSelector('客户名称', 'custId') },
            { ...invTypeSelector('发票类型', 'invTypeId') },
            {
              label: '对账结果',
              prop: 'reconcile',
              type: 'select',
              dicUrl: reconcileStatus(),
              search: true,
              display: false,
              hide: true,
              props: {
                label: 'name', value: 'code'
              }
            }
          ],
          // 修改页的表体
          columnBodyForFuncPage: {
            label: '表体信息', prop: 'businessFieldVoList	', icon: 'el-icon-s-order',
            column: [
              {
                label: '',
                labelPosition: 'top',
                prop: 'businessFieldVoList',
                type: 'dynamic',
                span: 24,
                children: {
                  index: false,
                  align: 'center',
                  headerAlign: 'center',
                  rowAdd: done => {
                    this.addStatus = true
                    done(this.defaultFormBody)
                  },
                  rowDel: (row, done) => {
                    if (Object.keys(this.form.businessFieldVoList).length === 1) {
                      this.$message.error('最少要保留一条')
                      return
                    }
                    done()
                  },
                  column: [
                    {
                      label: '货物或应税劳务、服务名称',
                      prop: 'goodsId',
                      type: 'select',
                      width: 120,
                      dicUrl: goodsDict(),
                      props: {
                        res: 'data.records',
                        label: 'name', value: 'id'
                      },
                      rules: [
                        {
                          required: true,
                          message: '货物或应税劳务、服务名称',
                          trigger: 'change'
                        }]
                    }, {
                      label: '规格型号',
                      prop: 'specification'
                    },
                    {
                      label: '单位',
                      prop: 'unit'
                    },
                    {
                      label: '数量',
                      prop: 'num'
                    },
                    {
                      label: '单价',
                      prop: 'price'
                    },
                    {
                      label: '含税金额',
                      prop: 'sumPriceTax',
                      rules: [
                        {
                          required: true,
                          message: '含税金额',
                          trigger: 'blur'
                        }]
                    },
                    { ...taxRateSelector('税率', 'taxId') },

                    {
                      label: '税额',
                      prop: 'taxAmount',
                      rules: [
                        {
                          required: true,
                          message: '税额',
                          trigger: 'blur'
                        }]
                    },
                    {
                      label: '不含税金额',
                      prop: 'extTaxAmount',
                      rules: [
                        {
                          required: true,
                          message: '不含税金额',
                          trigger: 'blur'
                        }]
                    },
                    {
                      label: '开票日期',
                      prop: 'invDate',
                      disabled: true
                      // type: 'date',
                      // format: 'yyyy-MM-dd hh:mm:ss',
                      // valueFormat: 'yyyy-MM-dd 00:00:00',
                      // searchRange: true
                    },
                    {
                      label: '发票代码',
                      prop: 'invCode',
                      disabled: true
                    },
                    {
                      label: '发票号码',
                      prop: 'invNum',
                      disabled: true
                    },
                    {
                      label: '发票状态',
                      prop: 'reconcile',
                      disabled: true
                    },
                    {
                      label: '对账状态',
                      prop: 'reconcile',
                      disabled: true
                    }

                  ]
                }
              }]
          }
        }
      }
    },
    methods: {
      // 统一回写选择器
      commonBackShow(formProp,value,callback,baseConfigProps) {
        console.log('baseConfigProps',baseConfigProps)
        const {label,value:valueKey}=baseConfigProps

        const name = this.form[formProp]
        if (name) {
          if (value) {
            callback({
              [label]: name,
              [valueKey]:value
            })
          }
        }
      },
      // 修改或者详情一些初始字典查询
      initDicts(data) {
        const { taxOrgId ,custId} = data
        this.getBankListBaseTax(taxOrgId)//根据纳税主体id查询开户行
        this.getCustBankInfo(custId)//根据客户id查询开户行
      },
          // 根据选择的客户查询开户行及 开户银行
    getCustBankInfo(id) {
      const column = _setTempThis.findObject(_setTempThis.option.group, 'custSubBank')
      customerDetail(id).then(res => {
        let datas = _get(res, 'data.data', {})
        let { bankCardList } = datas
        column.dicData = bankCardList
      })
    },

     getBankListBaseTax(id) { // 根据纳税主体 获取银行卡列表
      const column = _setTempThis.findObject(_setTempThis.option.group, 'invCompanySubBank')
      const params = {
        taxSubjectId: id
      }
      getBankCardByTaxId(params).then(res => {
        column.dicData = _get(res, 'data.data', [])
      })
    },
      getBusinessNo() {
        getBusinessNoType({ type: 1 }).then(res => {
          this.form.businessNo = res.data.data
        })
      },
      setFuncPageOptions() {
        if (isFunc) { // 修改 详情页
        // 表头设置
          let optList = cloneDeep(_get(this, 'option.column', []))
          optList = this.handleFuncShowClu(optList)

          const optListBody = _get(this, 'option.columnBodyForFuncPage', [])
          const optListBodyClu = _get(optListBody, 'column[0].children.column', [])
          if (optListBodyClu && optListBodyClu.length)optListBodyClu.forEach(i => { i.width = 140 })
          //
          let tempObj = {}
          tempObj = {
            ...optionsResult,
            group: [
              {
                label: '基础信息', span: 24, column: optList
              },
              {
                label: '表体信息', prop: 'businessFieldVoList	', icon: 'el-icon-s-order', ...optListBody
              }
            ]
          }
          this.$set(this, 'option', tempObj)
        }
      },
      handleFuncShowClu(options) {
        let resultFormClu = this.pageAttr.isAdd ? funcPageSet : funcPageSet.concat(funcPageSetOnlyAddShow)

        let tempArr = []
        if (options && options.length) {
          options.forEach((i, index) => {
            if (resultFormClu.includes(i.prop)) {
              let getBaseIndex = resultFormClu.indexOf(i.prop)
              i.span = 8
              i.hide = false
              i.display = true
              i.search = false
              i.sortInvoiceManagementIndex = getBaseIndex
              tempArr.push(i)
            }
          })
        }
        tempArr = uniqBy(tempArr, 'prop')
        tempArr = sortBy(tempArr, function(o) { return o.sortInvoiceManagementIndex })
        return tempArr
      },
      handletInvoiceList(page, data, callback) { // 发票列表
        getInvoiceList(page.currentPage, page.pageSize, { enableStatus: 1, ...data }).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      },
      handleTaxRateList(page, data, callback) { // 税率列表
        getTaxRateList(page.currentPage, page.pageSize, { enableStatus: 1, ...data }).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      },
      handleGetProjectsList(page, data, callback) { // 项目列表
        getProjectsList(page.currentPage, page.pageSize, data).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      },
      handleGetDeptList(page, data, callback) { // 部门列表
        getDeptList('',
          {
            ...data,
            enableStatus: 1,
            current: page.currentPage,
            size: page.pageSize
          }).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      },
      handleGetBankNameList(page, data, callback) {
        getBankTypeList(page.currentPage, page.pageSize, data).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      },
      handlePersonnelList(page, data, callback) { // 获取人员列表
        getPersonnelList(page.currentPage, page.pageSize, data).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      },
      handleCustomerList(page, data, callback) { // 项目列表
        getCustomerList(page.currentPage, page.pageSize, { enableStatus: 1, ...data }).then(res => {
          let data = _get(res, 'data.data.records', [])
          callback({
            total: res.data.data.total,
            data: data
          })
        })
      }
    }

  }

  function getOptionBaseType() {
    // 区分两个页面的option
    let optionsResult = {}
    if (isList) {
      optionsResult = {
        // list的表单配置
        lazy: true,
        rowKey: 'id',
        columnBtn: false,
        searchShow: true,
        searchShowBtn: false,
        searchMenuSpan: 6,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        border: true,
        index: true,
        selection: true,
        selectClearBtn: false,
        menuAlign: 'center',
        size: 'small',
        searchLabelWidth: 100
      }
    } else {
      optionsResult = {
        // 功能页的表单配置
        labelWidth: 144,
        submitBtn: false,
        emptyBtn: false,
        detail: false
      }
    }
    return { optionsResult }
  }

  /* 纳税主体选择器-配置 */
  function taxpayerSelector(label, prop) {
    // taxOrgName
    let baseConfig = {
      label,
      prop,
      hide: true,
      display: false,
      search: true,
      type: 'table',
      children: {
        border: true,
        column: [
          {
            label: '纳税主体编码',
            prop: 'orgCode',
            width: 120
          },
          {
            label: '纳税主体名称',
            search: true,
            searchSpan: 8,
            prop: 'orgName',
            searchLabelWidth: 120

          }
        ]
      },
      formatter: row => {
        const { orgName } = row || ''
        taxPayChange(row)
        return orgName
      },
      onLoad: ({ page, value, data }, callback) => {
        _setTempThis.commonBackShow('taxOrgName',value,callback,baseConfig.props)
        if (data || page) _setTempThis.handleGetTaxList(page, data, callback)
      },
      props: {
        label: 'orgName',
        value: 'id'
      }
    }
    // 纳税主体操作后的交互
    function taxPayChange(row) {
      if (!row || !Object.keys(row).length || !isFunc) return
      const { taxSubjectNum, address, phone, id } = row
      _setTempThis.form.invCompanyTaxSubjectNum = taxSubjectNum || '', // 开票单位纳税人识别号
      _setTempThis.form.invCompanyAddress = `${address || ''} ${phone || ''}` // 纳税主体地址、电话'
      
      _setTempThis.getBankListBaseTax(id)
    }

    if (isFunc) {
      baseConfig.rules = [
        {
          required: true,
          message: '纳税主体',
          trigger: 'change'
        }]
      // 详情 修改页
      if (prop === 'taxOrgName') {
        baseConfig = {
          label, prop, display: false, hide: true
        }
      } else if (prop === 'taxOrgId') {
        baseConfig.display = true
        baseConfig.hide = false
      }
    }
    return baseConfig
  }

  /* 申请人-配置 */
  function applyUserSelector(label, prop) {
    let baseConfig = {
      label: label,
      prop: prop,
      search: true,
      hide: true,
      display: false,
      type: 'table',
      children: {
        border: true,
        column: [
          {
            label: '人员编码',
            prop: 'code',
            width: 120
          },
          {
            label: '人员名称',
            search: true,
            searchSpan: 8,
            prop: 'name',
            searchLabelWidth: 120

          }
        ]
      },
      formatter: row => {
        const { name } = row || ''
        return name
      },
      onLoad: ({ page, value, data }, callback) => {
        _setTempThis.commonBackShow('applyUserName',value,callback,baseConfig.props)
        if (data || page) _setTempThis.handlePersonnelList(page, data, callback)
      },
      props: {
        label: 'name',
        value: 'code'
      }

    }
    if (isList) {
      // 列表
      if (prop === 'applyUserName') {
        baseConfig = {
          label: '申请人',
          prop: 'applyUserName'
        }
      }
    } else {
    // 修改、详情页
      baseConfig.props.value = 'id'
      if (prop === 'applyUser') {
        baseConfig.hide = false
        baseConfig.display = true
      } else {
        baseConfig.hide = true
        baseConfig.display = false
      }
    }
    return baseConfig
  }

  /* 申请部门-配置 */
  function deptSelector() {
    let baseConfig = {
      label: '申请部门',
      prop: 'deptId',
      type: 'table',
      children: {
        border: true,
        column: [
          {
            label: 'id',
            width: 120,
            prop: 'id'
          },
          {
            label: '部门名称',
            search: true,
            searchSpan: 8,
            prop: 'deptName'
          }
        ]
      },
      formatter: row => {
        if (!row.deptName) return ''
        return row.deptName
      },
      onLoad: ({ page, value, data }, callback) => {
        _setTempThis.commonBackShow('deptName',value,callback,baseConfig.props)
        if (data || page) _setTempThis.handleGetDeptList(page, data, callback)
      },
      props: {
        label: 'deptName',
        value: 'id'
      },
      rules: [
        {
          required: true,
          message: '请选择申请部门',
          trigger: 'change'
        }
      ],
      span: 8
    }
    if (isList) {
      baseConfig = {
        label: '申请部门',
        prop: 'deptName'
      }
    }
    return baseConfig
  }

  function projectSelector() {
    let baseConfig = {
      label: '项目',
      prop: 'projectId',
      type: 'table',
      children: {
        border: true,
        column: [
          {
            width: 100,
            label: '项目编码',
            search: true,
            prop: 'code'
          },
          {
            label: '项目名称',
            search: true,
            prop: 'name'
          }
        ]
      },
      formatter: row => {
        if (!row.name) return ''
        return row.name
      },
      onLoad: ({ page, value, data }, callback) => {
      _setTempThis.commonBackShow('projectName',value,callback,baseConfig.props)
        if (data || page) _setTempThis.handleGetProjectsList(page, data, callback)
      },
      props: {
        label: 'name',
        value: 'id'
      },
      rules: [
        {
          required: true,
          message: '请选择项目',
          trigger: 'change'
        }
      ],
      span: 8
    }

    if (isList) {
      baseConfig = {
        label: '项目',
        prop: 'projectName'
      }
    }
    return baseConfig
  }

  /* 客户-配置 */
  function custSelector(label, prop, ifOnlyShow) {
    let baseConfig = {
      label,
      prop,
      search: true,
      hide: true,
      display: false,
      type: 'table',
      rules: [
        {
          required: true,
          message: label,
          trigger: 'change'
        }],
      children: {
        border: true,
        column: [
          {
            label: '客户编码',
            prop: 'code',
            width: 120
          },
          {
            label: '客户名称',
            search: true,
            searchSpan: 8,
            prop: 'name',
            searchLabelWidth: 120

          }
        ]
      },
      formatter: row => {
        const { name } = row || ''
        custChange(row)
        return name
      },
      onLoad: ({ page, value, data }, callback) => {
        _setTempThis.commonBackShow('custName',value,callback,baseConfig.props)
        if (data || page) _setTempThis.handleCustomerList(page, data, callback)
      },
      props: {
        label: 'name',
        value: 'id'
      }

    }
    // 功能页 客户名称选择后的交互
    function custChange(row) {
      if (!row || !Object.keys(row).length || !isFunc) return
      const { taxNum, address, phone, id } = row
      _setTempThis.form.custTaxNum = taxNum || ''
      _setTempThis.form.custAddress = `${address || ''} ${phone || ''}`
      this.getCustBankInfo(id)
    }

    if (isList) {
      baseConfig.rules = null
      if (ifOnlyShow) {
        baseConfig = {
          label, prop
        }
      } else if (!ifOnlyShow) {
        baseConfig.hide = true
        baseConfig.display = false
      }
    } else if (isFunc) {
      baseConfig.hide = false
      baseConfig.display = true
    }
    return baseConfig
  }

  /* 银行类别-配置 */
  function bankSelector(label, prop) {
    let baseConfig = {
      label: label,
      labelWidth: 150,
      prop: prop,
      type: 'table',
      children: {
        border: true,
        column: [
          {
            label: 'id',
            width: 120,
            prop: 'id'
          },
          {
            label: '名称',
            search: true,
            searchSpan: 8,
            prop: 'bankName'
          }
        ]
      },
      formatter: (row) => {
        if (!row.bankName) return ''
        return row.bankName
      },
      onLoad: ({ page, value, data }, callback) => {
        if (data || page) _setTempThis.handleGetBankNameList(page, data, callback)
      },
      props: {
        label: 'bankName',
        value: 'id'
      },
      rules: [
        {
          required: true,
          message: '请选择银行类别'
        }
      ],
      span: 8
    }
    let baseSelectConfig = {
      label,
      prop,
      type: 'select',
      dicData: [],
      change: ({ value, column }) => {
        if (!value) return
        const { dicData, props: { value: subBankId }} = column

        // 纳税主体开户行-将选择的银行卡号展示
        if (prop === 'invCompanySubBank') {
          let findTarget = dicData.find(i => value === i[subBankId])
          _setTempThis.form.invCompanyBankAccount = _get(findTarget, 'bankNum', '')
        }

        // 客户开户行-将选择的银行卡号展示
        if (prop === 'custSubBank') {
          let findTarget = dicData.find(i => value === i[subBankId])
          _setTempThis.form.custBankAccount = _get(findTarget, 'bankNum', '')
        }
      },
      rules: isFunc ? [{ required: true, message: label, trigger: 'change' }] : null,
      props: {
        label: 'bankNum',
        value: 'bankId'
      }
    }
    if (prop === 'custSubBank') { // 客户开户行
      baseSelectConfig.props.label = 'subBankName'
      baseSelectConfig.props.value = 'id'
    } else if (prop === 'invCompanySubBank') {
      baseSelectConfig.props.label = 'subBankName'
      baseSelectConfig.props.value = 'subBankId'
    }
    if (isList) {
      // 列表页 invCompanySubBank custSubBank
      baseConfig = {
        label, prop
      }
    } else {
      // 详情 修改页
      baseConfig.hide = false
      baseConfig.display = true
    }
    return isFunc ? baseSelectConfig : baseConfig
  }

  /* 发票类型-配置 */
  function invTypeSelector(label, prop) {
    let baseConfig = {
      label: label,
      prop: prop,
      search: true,
      hide: true,
      display: false,
      type: 'table',
      children: {
        border: true,
        column: [
          {
            label: '发票类型编码',
            prop: 'dictKey',
            width: 120
          },
          {
            label: '发票类型名称',
            search: true,
            searchSpan: 8,
            prop: 'dictValue',
            searchLabelWidth: 120

          }
        ]
      },
      formatter: row => {
        const { dictValue } = row || ''
        return dictValue
      },
      onLoad: ({ page, value, data }, callback) => {
        _setTempThis.commonBackShow('invTypeName',value,callback,baseConfig.props)
        if (data || page) _setTempThis.handletInvoiceList(page, data, callback)
      },
      props: {
        label: 'dictValue',
        value: 'id'
      }

    }
    if (isList) {
      // 列表
      if (prop === 'invTypeName') {
        baseConfig = {
          label, prop
        }
      }
    } else {
      // 详情 修改页
      baseConfig.hide = prop === 'invTypeName'
      baseConfig.display = prop !== 'invTypeName'
    }

    return baseConfig
  }

  /* 申请日期-配置 */
  function applyDateSeting(label, prop, ifOnlyShow) {
    let baseConfig = {
      label: '申请日期',
      prop: 'applyDate',
      search: true,
      hide: true,
      display: false,
      type: 'date',
      format: 'yyyy-MM-dd hh:mm:ss',
      valueFormat: 'yyyy-MM-dd 00:00:00',
      searchRange: true
    }
    if (isList) {
      if (ifOnlyShow) {
        baseConfig = {
          label, prop
        }
      }
    } else {
      // if (ifOnlyShow) {
      //   baseConfig = {}
      // } else {
      //   baseConfig.display = true
      //   baseConfig.hide = false
      // }
      baseConfig.display = !ifOnlyShow
      baseConfig.hide = !!ifOnlyShow
    }
    return baseConfig
  }

  /* 回款类型-配置 */
  function payStatusSelector(label, prop) {
    let baseConfig = {
      label, prop,
      type: 'select',
      dicUrl: getPayStatusList(),
      props: {
        label: 'name', value: 'code'
      },
      rules: [
        {
          required: true,
          message: label,
          trigger: 'change'
        }]
    }
    if (isList) {
      baseConfig = {
        label, prop
      }
    } else {
      baseConfig.prop = 'payStatus'
    }
    return baseConfig
  }

  function invCompanyBankAccountSelector(label, prop) {
    let baseConfig = {
      label,
      prop,
      type: 'select',
      dicData: [],
      change: ({ value, column }) => {
      },
      rules: isFunc ? [{ required: true, message: label, trigger: 'change' }] : null,
      props: {
        label: 'bankNum',
        value: 'bankId'
      }
    }
    if (isList) {
      baseConfig = {
        label,
        prop
      }
    }
    return baseConfig
  }

  /* 税率-配置 */
  function taxRateSelector(label, prop) {
    let baseConfig = {
      label,
      prop,
      type: 'table',
      rules: [
        {
          required: true,
          message: '税率',
          trigger: 'blur'
        }],
      children: {
        border: true,
        column: [
          {
            label: '税率编码',
            searchLabelWidth: 100,
            search: true,
            prop: 'dictKey',
            width: 120
          },
          {
            label: '税率名称',
            searchLabelWidth: 100,
            search: true,
            prop: 'dictValue'
          }
        ]
      },
      formatter: row => {
        const { dictValue } = row || ''
        return dictValue
      },
      onLoad: ({ page, value, data }, callback) => {
        if (data || page) _setTempThis.handleTaxRateList(page, data, callback)
      },
      props: {
        label: 'dictValue',
        value: 'id'
      }
    }
    return baseConfig
  }

  return mixin
}
